package org.example.leetcpde;

import org.example.INode;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Node;

import java.util.Deque;
import java.util.LinkedList;
import java.util.List;
import java.util.Stack;

public class removeNthFromEnd implements IListNode {

    @Test
    void removeNthFromEnd() {
        ListNode fill = new ListNode().fill("[1,2]");
        ListNode node = removeNthFromEnd(fill, 1);
        System.out.println(22);
    }

    public ListNode removeNthFromEnd(ListNode head,
                                     int n) {
        ListNode root = new ListNode(0, head);
        ListNode f = head, s = root;
        for (int i = 0; i < n; i++) {
            f = f.next;
        }

        for (; f != null; f = f.next, s = s.next) {
        }

        s.next = s.next.next;
        return root.next;
    }
}
